'''
https://leetcode.cn/problems/container-with-most-water/description/
'''
from typing import List


class Solution:
    def maxArea(self, height: List[int]) -> int:
        ans = 0
        l, r = 0, len(height) - 1
        while l <= r:
            if height[l] <= height[r]:
                ans = max(ans, (r-l) * height[l])
                l += 1
            else:
                ans = max(ans, (r-l) * height[r])
                r -= 1
        return ans